package com.gp.ssmplus.base.core.mybatis.model;

import com.gp.ssmplus.base.core.mybatis.common.utils.JsonUtils;
import lombok.Data;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * listEntityMap方法参数模型
 *
 * @author zyf
 * @date 2018/07/10
 */
@Data
public class ListModel {
    private String handlerName;
    private String params;

    public ListModel(HttpServletRequest request) {
        Map maps = request.getParameterMap();
        Map<String, Object> params = new HashMap<>();
        for (Iterator iter = maps.entrySet().iterator(); iter.hasNext(); ) {
            Map.Entry element = (Map.Entry) iter.next();
            String strKey = element.getKey().toString();
            String[] strObj = (String[]) element.getValue();
            params.put(strKey, strObj[0]);
        }
        String json = JsonUtils.beanToJson(params);
        this.params = json;
    }

    public String getHandlerName() {
        return handlerName;
    }

    public void setHandlerName(String handlerName) {
        this.handlerName = handlerName;
    }
}
